home *** CD-ROM | disk | FTP | other *** search
/ 130 MIDI Tool Box / 130 MIDI Tool Box.iso / mpui04 / mpuio4.bas next >
BASIC Source File  |  1988-08-12  |  2KB  |  141 lines

  1. DECLARE SUB Send.Data (MidiOut$)
  2. DECLARE SUB Read.Data (Byte%)
  3. DECLARE SUB Send.Command (Cmd%)
  4.  
  5.  
  6. '   MPUIO2.BAS
  7. '
  8. '   Routines pour IBM/MPU-401 avec Quick-Basic 4.00
  9. '   Routines for  IBM/MPU-401 with Quick-Basic 4.00
  10. '
  11. '   Michel Poirier
  12. '   MIDICOM, Montreal Fido 167/111
  13. '   (514) 744-7354 (data)
  14. '
  15.  
  16. Initial:
  17.  
  18. CLS
  19. KEY OFF
  20. DEFINT A-Z
  21. COLOR 7, 0
  22.  
  23. ' MPU-401 ports & commands...
  24.  
  25. Dataport = 816
  26. Comport = 817
  27. DSR = 128
  28. DRR = 64
  29.  
  30. Uart = 63
  31. Ack = 254
  32. Rst = 255
  33.  
  34. DIM DataByte AS STRING * 3
  35.  
  36. ' These Dump Requests are for a TX81Z on Channel 4
  37.  
  38. SysSetUp$ = CHR$(&HF0) + CHR$(&H43) + CHR$(&H23) + CHR$(&H7E) + "LM  8976S0" + CHR$(&HF7)
  39. VCED$ = CHR$(&HF0) + CHR$(&H43) + CHR$(&H23) + CHR$(&H3) + CHR$(&HF7)
  40. ACED$ = CHR$(&HF0) + CHR$(&H43) + CHR$(&H23) + CHR$(&H7E) + "LM  8976AE" + CHR$(&HF7)
  41.  
  42. Start:
  43.  
  44. Send.Command Rst
  45. Send.Command Uart
  46.  
  47. 'Send.Data SysSetUp$
  48.  
  49. Send.Data VCED$
  50.  
  51. 'Send.Data ACED$
  52.  
  53. PRINT "All numbers in Hexadecimal.": PRINT
  54. PRINT "Header : ": PRINT
  55.  
  56. Read.Data Byte
  57. PRINT HEX$(Byte), " System Exclusive"
  58.  
  59. Read.Data Byte
  60. PRINT HEX$(Byte), " YAMAHA ID Number"
  61.  
  62. Read.Data Byte
  63. PRINT HEX$(Byte), " Bulk Data on Channel"; Byte + 1
  64.  
  65. Read.Data Byte
  66. PRINT HEX$(Byte), " Function Number"
  67.  
  68. Read.Data Byte
  69. PRINT HEX$(Byte), " Data Size High"
  70. Size = Byte * 256
  71.  
  72. Read.Data Byte
  73. PRINT HEX$(Byte), " Data Size Low"
  74. Size = Size + Byte
  75.  
  76. PRINT : PRINT "Data : ": PRINT
  77.  
  78. FOR c = 1 TO Size
  79. Read.Data Byte
  80. Total = Total + Byte
  81. RSET DataByte$ = HEX$(Byte)
  82. PRINT DataByte$;
  83. NEXT c
  84.  
  85. PRINT : PRINT
  86.  
  87. Read.Data Byte
  88. PRINT HEX$(Byte), "Checksum"
  89. PRINT HEX$((NOT Total) + 1 AND 127), "Calculated Checksum"
  90.  
  91. PRINT
  92.  
  93. Read.Data Byte
  94. PRINT HEX$(Byte), "End of Exclusive"
  95.  
  96. Finish:
  97.  
  98. Send.Command Rst
  99.  
  100. END
  101.  
  102. SUB Read.Data (Byte)
  103. SHARED DRR, DSR, Comport, Dataport
  104.  
  105. WHILE (INP(Comport) AND DSR) = DSR: WEND
  106.  
  107. Byte = INP(Dataport)
  108.  
  109. END SUB
  110.  
  111. SUB Send.Command (Cmd%)
  112. SHARED DRR, DSR, Comport, Dataport
  113.  
  114. WHILE (INP(Comport) AND DRR) = DRR
  115. PURGE = INP(Dataport)
  116. WEND
  117.  
  118. OUT Comport, Cmd
  119.  
  120. PURGE = INP(Dataport)
  121.  
  122. END SUB
  123.  
  124. SUB Send.Data (MidiOut$)
  125. SHARED DRR, Comport, Dataport, Statport
  126.  
  127. FOR c = 1 TO LEN(MidiOut$)
  128.  
  129.      WHILE (INP(Comport) AND DRR) = DRR
  130.           PURGE = INP(Dataport)
  131.      WEND
  132.  
  133. OUT Dataport, ASC(MID$(MidiOut$, c, 1))
  134.  
  135. PURGE = INP(Dataport)
  136.  
  137. NEXT c
  138.  
  139. END SUB
  140.  
  141.